import java.util.Arrays;

/**
 * @Author 12629
 * @Description：
 */
public class Test {


    public static void main(String[] args) {
        String str = "ababc";
        String ret = str.substring(0,3);//[0,3)

        System.out.println(ret);

        ret = str.substring(2);

        System.out.println(ret);
        System.out.println("================");
        String str2 = "  fdsafsafdsa   fdsafsaf  ";
        System.out.println(str2);

        //去掉字符串的左右两边的空格 中间的空格无法去掉
        System.out.println(str2.trim());


        final int[] array = {1,2,3,4};
        array[0] = 99;
        //array = new int[10];

    }


    public static void main9(String[] args) {
        String str = "name=zhangsan&age=15";
       /* String[] ret = str.split("=|&");
        for (int i = 0; i < ret.length; i++) {
            System.out.println(ret[i]);
        }*/
        //可以再 第一次分割的基础上 进行第二次分割
        String[] ret = str.split("&");
        for (int i = 0; i < ret.length; i++) {
            //System.out.println(ret[i]);
            String x = ret[i];
            String[] ret2  = x.split("=");
            for (int j = 0; j < ret2.length; j++) {
                System.out.println(ret2[j]);
            }
        }
    }

    public static void main8(String[] args) {
        /*String str = "192.168.1.1";
        String[] ret = str.split("\\.");//   \.
        for (int i = 0; i < ret.length; i++) {
            System.out.println(ret[i]);
        }*/



        String str = "192\\168\\1\\1";
        String[] ret = str.split("\\\\");
        for (int i = 0; i < ret.length; i++) {
            System.out.println(ret[i]);
        }
    }


    public static void main7(String[] args) {
        String str = "hello abc world";
        String[] ret = str.split(" ",2);
        for (int i = 0; i < ret.length; i++) {
            System.out.println(ret[i]);
        }
    }

    public static void main6(String[] args) {
        String str = "ababcabcdabcde";
        String ret = str.replace("ab","9999");

        System.out.println(ret);


        ret = str.replace('a','8');
        System.out.println(ret);

        ret = str.replaceFirst("ab","pppp");

        System.out.println(ret);

        ret = str.replaceAll("ab","123");
        System.out.println(ret);

    }

    public static void main5(String[] args) {
        String s1 = "hello";
        char[] array = s1.toCharArray();
        System.out.println(Arrays.toString(array));


        char[] array2 = {'a','b','c'};

        String str2 = new String(array2);

        System.out.println(str2);


        String s = String.format("%d-%d-%d", 2019, 9,14);
        System.out.println(s);
    }

    public static void main4(String[] args) {


        String s1 = "hello";

        //转变为大写 不是在原来的基础上  转变  是转变成大写后是一个新的对象
        String ret = s1.toUpperCase();

        System.out.println(s1);
        System.out.println(ret);


        String s2 = "HEllo";

        String ret2 = s2.toLowerCase();
        System.out.println(s2);
        System.out.println(ret2);


       /* int data = Integer.parseInt("198");
        System.out.println(data);*/


        /*String s = String.valueOf(19);
        System.out.println(s);*/

        /*String s1 = "ababcabcd";

        int index = s1.lastIndexOf("abc",4);
        System.out.println(index);
*/
        /*int index = s1.indexOf("abc",3);
        System.out.println(index);
*/


        //从头到后  查某个字符 第一次出现的下标
       /* int index = s1.indexOf('l',3);
        System.out.println(index);*/
        /*for (int i = 0; i < s1.length(); i++) {
            char ch = s1.charAt(i);
            System.out.println(ch);
        }*/

    }

    public static void main3(String[] args) {
        String s1 = new String("abc");
        String s2 = new String("Abc");
        //System.out.println(s1 == s2);

        //比较内容  返回值是true 或者 是false  boolean类型的
        System.out.println(s1.equals(s2));

        //strcmp
        //str1: abc   str2:acd
        /**
         * //s1 和 s2 进行比较
         * 如果s1 > s2 返回正数
         * 如果s1 == s2 返回0
         * 如果s1 < s2 返回负数
         */
        System.out.println(s1.compareTo(s2));
        /**
         * 忽略大小写
         *
         */
        System.out.println(s1.compareToIgnoreCase(s2));

    }
    public static void main2(String[] args) {
     /*   String s1 = new String("hello");
        String s2 = new String("world");
        String s3 = s1;

        System.out.println(s1.length());
        System.out.println(s2.length());
        System.out.println(s3.length());
*/

        String str4 = "";
        System.out.println(str4.length());
        System.out.println(str4.isEmpty());
        String str5 = null;
        //System.out.println(str5.length());
        System.out.println(str5.isEmpty());

    }
    public static void main1(String[] args) {
        //"hello" 字符串常量 ，没有\0 标记结尾
        String  str = "hello";
        System.out.println(str);


        String str2 = new String();
        System.out.println(str2);

        String str3 = new String("pppp");
        System.out.println(str3);

        char[] array ={'a','b','c'};
        String str4 = new String(array,1,2);
        System.out.println(str4);

    }
}
